import React, { Component } from "react"; // 在组件头部引用
import { Menu } from "element-react";
import "./Slider.css";
import { Link } from "react-router-dom";
class Slider extends React.Component {
  constructor(props) {
    super(props);
    this.state = {};
  }
  reanderMenus() {
    let item = JSON.parse(this.props.item);

    if (item.children.length != 0) {
      return (
        <Menu.SubMenu
          index={item.webUrl}
          title={
            <span>
              <i
                className={item.icon ? "iconfont " + item.icon : "iconfont"}
              ></i>
              <span>{item.cateName}</span>
            </span>
          }
        >
          {item.children.map((items) => {
            return (
              <Slider
                key={JSON.stringify(items)}
                item={JSON.stringify(items)}
              />
            );
          })}
        </Menu.SubMenu>
      );
    }
    return (
      <Menu.Item index={item.webUrl}>
        <i className={item.icon ? "iconfont " + item.icon : "iconfont"}></i>
        {item.cateName}
      </Menu.Item>
    );
  }

  render() {
    return this.reanderMenus();
  }
}
export default Slider;
